package com.bsoft.exchange.service;

import com.bsoft.exchange.dao.hss.MedicalAppointmentMapper;
import com.bsoft.exchange.domain.MedicalAppointment;
import com.bsoft.exchange.vo.MedicalAppointmentVO;
import com.github.dozermapper.core.DozerBeanMapperBuilder;
import com.github.dozermapper.core.Mapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class MedicalAppointmentService {

    @Autowired
    private MedicalAppointmentMapper medicalAppointmentMapper;

    private Mapper mapper = DozerBeanMapperBuilder.buildDefault();

    /**
     * 获取体检预约列表
     * @param identityType 证件类型
     * @param identityNo 证件号码
     * @param orgId 机构编号
     * @return 体检预约列表
     */
    public List<MedicalAppointmentVO> getListByParams(String identityType, String identityNo, String orgId) {
        List<MedicalAppointment> medicalAppointments = medicalAppointmentMapper.queryByIdentityTypeAndIdentityNoAndOrgId(identityType, identityNo, orgId);
        List<MedicalAppointmentVO> medicalAppointmentVOS = medicalAppointments.stream().map(medicalAppointment -> {
            medicalAppointment.setRegRecordCode(StringUtils.trim(medicalAppointment.getRegRecordCode()));
            return mapper.map(medicalAppointment,MedicalAppointmentVO.class);
        }).collect(Collectors.toList());
        return medicalAppointmentVOS;
    }


}
